home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / archiver / arc.zoo / arctst.c < prev    next >
C/C++ Source or Header  |  1989-01-29  |  1KB  |  59 lines

  1. /*
  2.  * $Header: arctst.c,v 1.4 88/04/19 01:40:28 hyc Exp $
  3.  */
  4.  
  5. /*
  6.  * ARC - Archive utility - ARCTST
  7.  * 
  8.  * Version 2.12, created on 02/03/86 at 23:00:40
  9.  * 
  10.  * (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  11.  * 
  12.  * By:  Thom Henderson
  13.  * 
  14.  * Description: This file contains the routines used to test archive integrity.
  15.  * 
  16.  * Language: Computer Innovations Optimizing C86
  17.  */
  18. #include <stdio.h>
  19. #include "arc.h"
  20.  
  21. void    openarc();
  22. int    readhdr(), unpack();
  23.  
  24. void
  25. tstarc()
  26. {                /* test integrity of an archive */
  27.     struct heads    hdr;    /* file header */
  28.     long            arcsize;/* archive size */
  29. #ifndef __STDC__
  30.      long         ftell();        
  31. #endif
  32.     openarc(0);        /* open archive for reading */
  33.     fseek(arc, 0L, 2);    /* move to end of archive */
  34.     arcsize = ftell(arc);    /* see how big it is */
  35.     fseek(arc, 0L, 0);    /* return to top of archive */
  36.  
  37.     while (readhdr(&hdr, arc)) {
  38.         if (ftell(arc) + hdr.size > arcsize) {
  39.             printf("Archive truncated in file %s\n", hdr.name);
  40.             nerrs++;
  41.             break;
  42.         } else {
  43.             printf("Testing file: %-12s  ", hdr.name);
  44.             fflush(stdout);
  45.             if (unpack(arc, (FILE *)NULL, &hdr))
  46.                 nerrs++;
  47.             else
  48.                 printf("okay\n");
  49.         }
  50.     }
  51.  
  52.     if (nerrs < 1)
  53.         printf("No errors detected\n");
  54.     else if (nerrs == 1)
  55.         printf("One error detected\n");
  56.     else
  57.         printf("%d errors detected\n", nerrs);
  58. }
  59.